// import $http from './request.js'
// 封装公共方法

// 获取授权(未使用)
export const wxLogin = () => {
	uni.login({
		provider: 'weixin',
		success: (res) => {
			// 获取登录凭证
			let code = res.code
			uni.getUserInfo({
				provider: 'weixin',
				success: async (res) => {
					// 获取用户信息
					let userinfo = res.userInfo
					const result = await uni.request({
						url: 'https://api.weixin.qq.com/sns/jscode2session',
						data: {
							appid: 'wxc402935c921d03b2',
							secret: '52751c06c0a9c1095f4040c837b7d92a',
							js_code: code,
							grant_type: 'authorization_code',
						},
						success: (res) => {
							let userId = res.data.openid
							userinfo.userId = userId
						},
					})
				},
			})
		},
	})
}
